package util;

import java.io.File;
import java.io.FilenameFilter;

public class ClassEverythingUp {

	public static void main(String[] args) {
		
		String sourceDir = "sounds";
		String destDir = "src/sounds";
		//final String filenameContains = "loop";
		final String filenameContains = null;
		
		
		File source = new File(sourceDir);
		
		SoundToClass stc = new SoundToClass(false);
		
		
		FilenameFilter filter = new FilenameFilter() {
			
			@Override
			public boolean accept(File dir, String name) {
				
				if (filenameContains != null && !name.contains(filenameContains)) {
					return false;
				}
				
				for (String type : SoundToClass.getSupportedFileTypes()) {
					if (name.contains("." + type.toLowerCase())) {
						return true;
					}
				}
				
				return false;
			}
		};
		
		for (File f : source.listFiles(filter)) {
			
			
			stc.soundToClass(f, new File(destDir, className(f)), "sounds");
		}
		
		
		
		
	}
	
	private static String className(File f) {
		//return SoundToClass.className(f.getName());
		
		String name = f.getName().split("\\.")[0];
		name = name.replaceAll("-", "");
		
		return capitalize( name ) + ".java";
	}
	
	private static String capitalize(String name) {
		return name.substring(0, 1).toUpperCase() + name.substring(1);
	}
	
	
}
